package com.yogurt.edu.controller;


import com.yogurt.edu.entity.subject.OneSubject;
import com.yogurt.edu.service.SubjectService;
import com.yogurt.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * <p>
 * 课程科目 前端控制器
 * </p>
 *
 * @author yogurt
 * @since 2020-07-09
 */
@RestController
@RequestMapping("/eduservice/subject")
@CrossOrigin
public class SubjectController {
    @Autowired
    private SubjectService subjectService;

    //添加课程分类
    @PostMapping("/add")
    public Result addSubject(MultipartFile file){
        subjectService.add(file,subjectService);
        return Result.ok();
    }

    //课程分类列表(树形结构)
    @GetMapping("/findAll")
    public Result findAllSubject(){
        List<OneSubject> list = subjectService.findAllSubject();
        return Result.ok().data("list",list);
    }
}

